package com.example.comsys.service.impl;

import javax.annotation.PostConstruct;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * TODO
 *
 * @author wjh
 * @date 2020/2/18, 周二
 */
// @Service
public class TestServiceImpl implements BeanNameAware, BeanClassLoaderAware,  BeanFactoryAware, InitializingBean, BeanPostProcessor,
    DisposableBean {

  @Override
  public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
    System.out.println("postProcessBeforeInitialization");

    return bean;
  }

  @PostConstruct
  public void init() {
    System.out.println("post construct");
  }

  @Override
  public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
    System.out.println("postProcessAfterInitialization");

    return bean;
  }

  @Override
  public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
    System.out.println("我知道了创建我的工厂-" + beanFactory);
  }

  @Override
  public void setBeanName(String name) {

    System.out.println("我知道了自己的名字-" + name);
  }

  @Override
  public void afterPropertiesSet() throws Exception {

    System.out.println("InitializingBean -afterPropertiesSet");

  }

  @Override
  public void setBeanClassLoader(ClassLoader classLoader) {
    System.out.println("setBeanClassLoader" + classLoader);

  }

  @Override
  public void destroy() throws Exception {

  }
}
